<template>
	<scroll-view class="backview" bounces="false">
		<lexiconNavVue title="BABY词库" />
		<view class="top-menu">
		</view>
		<scroll-view class="words-scroll" :style="{ height: scrollHeight + 'px'}" scroll-y
			:scroll-with-animation='true'>
			<view class="lexIcon-back">
				<block v-for="(item,index) in assetsList" :key="index">
					<lexIconCellTwo :courseData="item" rightStr="GO" :dataIndex="index" @wordClicked="wordClicked">
					</lexIconCellTwo>
				</block>
			</view>
		</scroll-view>
	</scroll-view>
</template>

<script>
	import lexIconCellTwo from '../../components/lexIconCom/lexIconCellTwo.vue'
	export default {
		components: {
			lexIconCellTwo
		},
		data() {
			return {
				scrollHeight: uni.getSystemInfoSync().windowHeight,
				menuIndex: 0,
				assetsList: []
			}
		},
		onLoad(options) {
			this.wordModel = JSON.parse(options.wordModel);
			this.navTitle = this.wordModel.title;
			this.getWordListData();
		},
		onReady() {
			const that = this
			uni.createSelectorQuery().select('.top-menu').boundingClientRect(rect => {
				that.scrollHeight = uni.getSystemInfoSync().windowHeight - rect.bottom;
			}).exec();
		},
		methods: {
			getWordListData() {
				this.$http.babyList({}).then(res => {
					if (res.code === 200) {
						var listData = res.data.map(item => {
							item.dictLabel = item.name;
							item.dictUrl = item.imgUrl;
							item.tag = '开始点读'
							return item
						})
						this.assetsList = listData;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			wordClicked(selectIndex) {
				const selectData = this.assetsList[selectIndex];
				uni.navigateTo({
					url: '/pages/lexicon/babyVocabularyMapDetail?wordModel=' + JSON.stringify(selectData) + '&wordType=' +
						'product',
				})
			}
		}
	}
</script>

<style lang="less">
	.backview {
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		top: 0;
		right: 0;
		background: #fff7dd;
	}

	.top-menu {
		width: 90%;
		margin-left: 5%;
		height: 5px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
	}

	.menuclass {
		width: 90px;
		height: 28px;
		margin-top: 8px;
		line-height: 28px;
		border-radius: 5px;
		background: #000;
		font-size: 13px;
		font-weight: 900;
		text-align: center;
		color: white;
	}

	.activeClass {
		width: 90px;
		height: 28px;
		line-height: 28px;
		border-radius: 5px;
		background: #e7e7e7;
		font-size: 13px;
		font-weight: 900;
		text-align: center;
		color: black;
		box-shadow: 0px 5px 0px 0px rgba(204, 204, 204, 1);
	}

	.lexIcon-back {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 20px;
	}
</style>